


import {
  get,
  post,
  put,
  del,
} from "./base_service"


/**
 * 佳宝首页相关接口
 *
 * allen  2023-12-19
 */

/**
 * 
 * 获取我的小店商品列表
 *
 * }
 */
const queryMyShopGoodList = () => {
  return new Promise((resolve, reject) => {
    get("/api/front/little/shop/list?page=1&limit=6").then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.message)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}

const queryShopGoodList = (userId) => {
  return new Promise((resolve, reject) => {
    get("/api/front/little/shop/list?page=1&limit=6" + "&userId=" + userId).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.message)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}


/**
* 
* 获取别人的小店商品列表
*
* 
*/
const queryOtherShopGoodList = (userId) => {
  return new Promise((resolve, reject) => {
    get("/api/front/little/shop/list?page=1&limit=6" + "&userId=" + userId).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.message)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}
/**
  * 
  * 删除我的小店里面的商品
  * data:{
  *     productIds:[]
  *   }
  * }
  */
const deleteMyShopGoods = (data) => {
  return new Promise((resolve, reject) => {
    del("/api/front/little/shop/del", data).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.message)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}

/**
 * 
 * 添加商品到我的小店
 *   data:{
 *     productIds:[]
 *   }
 * }
 */
const addGoodsToMyShop = (data) => {
  return new Promise((resolve, reject) => {
    post("/api/front/little/shop/create", data).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.message)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}





module.exports = {
  queryMyShopGoodList,
  deleteMyShopGoods,
  addGoodsToMyShop,
  queryOtherShopGoodList,
  queryShopGoodList
}

